package com.sk.cardeal.adapter;

import android.support.annotation.Nullable;

import com.chad.library.adapter.base.BaseMultiItemQuickAdapter;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.sk.cardeal.R;
import com.sk.cardeal.entity.WorkFormDetails;

import java.util.List;

/**
 * Created by sk on 2018/4/18.
 */

public class SettlementCashAdapter extends BaseMultiItemQuickAdapter<WorkFormDetails.ReturnObjectBean.RepairOrderDetailListBean,BaseViewHolder> {

    /**
     * Same as QuickAdapter#QuickAdapter(Context,int) but with
     * some initialization data.
     *
     * @param data A new list is created out of this one to avoid mutable list
     */
    public SettlementCashAdapter(List<WorkFormDetails.ReturnObjectBean.RepairOrderDetailListBean> data) {
        super(data);
        addItemType(1, R.layout.cash_project);
        addItemType(2,R.layout.cash_parts);
        addItemType(3,R.layout.cash_parts);
    }

    @Override
    protected void convert(BaseViewHolder helper, WorkFormDetails.ReturnObjectBean.RepairOrderDetailListBean item) {
        switch (item.getItemType()){
            case 1:
                helper.setText(R.id.project_name,item.getProject_name())
                        .setText(R.id.tv_price,"￥"+String.valueOf(item.getOtherPrice()));
                break;
            case 2:
                helper.setText(R.id.parts_name,item.getPartName())
                        .setText(R.id.tv_price,"￥"+String.valueOf(item.getOtherPrice()))
                        .setText(R.id.tv_num,"×"+item.getNum());

                break;
            case 3:
                helper.setText(R.id.parts_name,item.getOtherName())
                        .setText(R.id.tv_price,"￥"+String.valueOf(item.getOtherPrice()))
                        .setText(R.id.tv_num,item.getOtherRemark());
                break;
        }
    }
}
